﻿using System;
using System.Data.Entity;
using System.Data.Objects;
using System.Data.Entity.Infrastructure;

namespace Rainr.EFClient
{
    /// <summary>
    /// 数据上下文扩展
    /// </summary>
    public static class DbContextExtensions
    {
        /// <summary>
        /// 获得数据上下文中的对象上下文。
        /// </summary>
        /// <param name="dbContext">数据上下文对象</param>
        /// <returns>对象上下文</returns>
        public static ObjectContext GetObjectContext(this DbContext dbContext)
        {
            return ((IObjectContextAdapter)dbContext).ObjectContext;
        }
    }
}
